package cn.cdu.data.controller;

import cn.cdu.data.service.IResourceAnalysisService;
import cn.cdu.data.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/zwz/resource")
@Api(tags = "资源分析接口")
public class ResourceAnalysisController {

    @Autowired
    private IResourceAnalysisService resourceAnalysisService;

    @GetMapping("/stats")
    @ApiOperation("获取统计数据")
    public ResourceStatsVO getStats(
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate,
            @RequestParam(required = false) String departmentId,
            @RequestParam(required = false) String doctorId) {
        return resourceAnalysisService.getStats(startDate, endDate, departmentId, doctorId);
    }

    @GetMapping("/trend")
    @ApiOperation("获取预约趋势数据")
    public List<ResourceTrendVO> getTrend(
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate,
            @RequestParam(required = false) String departmentId,
            @RequestParam(required = false) String doctorId) {
        return resourceAnalysisService.getTrend(startDate, endDate, departmentId, doctorId);
    }

    @GetMapping("/status")
    @ApiOperation("获取预约状态分布")
    public ResourceStatusVO getStatus(
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate,
            @RequestParam(required = false) String departmentId,
            @RequestParam(required = false) String doctorId) {
        return resourceAnalysisService.getStatus(startDate, endDate, departmentId, doctorId);
    }

    @GetMapping("/department")
    @ApiOperation("获取科室分布数据")
    public List<ResourceDepartmentVO> getDepartment(
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate,
            @RequestParam(required = false) String departmentId,
            @RequestParam(required = false) String doctorId) {
        return resourceAnalysisService.getDepartmentDistribution(startDate, endDate, departmentId, doctorId);
    }

    @GetMapping("/department/comparison")
    @ApiOperation("获取科室对比数据")
    public List<ResourceDepartmentVO> getDepartmentComparison(
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate,
            @RequestParam(required = false) String departmentId,
            @RequestParam(required = false) String doctorId) {
        return resourceAnalysisService.getDepartmentComparison(startDate, endDate, departmentId, doctorId);
    }

    @GetMapping("/department/trend")
    @ApiOperation("获取科室趋势数据")
    public List<ResourceDepartmentTrendVO> getDepartmentTrend(
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate,
            @RequestParam(required = false) String departmentId,
            @RequestParam(required = false) String doctorId) {
        return resourceAnalysisService.getDepartmentTrend(startDate, endDate, departmentId, doctorId);
    }
} 